<template>
   	<div class="container" v-title data-title='写跟进'>
		<Header title="写跟进"></Header>
		<textarea class="followTextarea" placeholder="请填写跟进内容,200长度限制" v-model="remark"></textarea>
		<div class="operation-btn">
			<button class="btn btn-line btn-primary" @click="btnSubmit" v-show="btnShow">提交</button>
			<button class="btn btn-line btn-cancel" @click="btnCancel">取消</button>
		</div>
    </div>
</template>
<script>
	export default{
		data(){
			return {
				remark: '',
				btnShow: true
			}
		},
		components: {

		},mounted:function(){
            
		},
		methods:{
			btnCancel(){
				var id=this.$route.params.id;
				this.$router.push({name: 'declareDetail',params:{id:id}})
			},
			btnSubmit(){
				var _self = this;
				var flag = true;
				if(!_self.remark){
					flag = false;
					layer.msg("请填写跟进内容",{
						time: 2000
					});
				}
				if(_self.remark.length > 200){
					flag = false;
					layer.msg("跟进内容不能超过200字符",{
						time: 2000
					});
				}
				if(flag){
					_self.btnShow = false;
					var params = {};
					params.remark = _self.remark;
					//客户报备记录Id
					var id = this.$route.params.id;
					params.customerPremisesId = id;
					var body = {};
					body.params = params;
					var url = this.utilHelper.apiUrl+'/api/addFollow';
					this.$http.post(url,body).then((response)=>{
						var body = response.body;
						if(body.result == 1){
                            _self.btnShow = true;
							layer.msg("操作成功",{
								time: 2000
							}, function(){
								_self.$router.push({name: 'declareDetail',params:{id:id}})
							});
						}else{
							_self.btnShow = true;
							layer.msg("操作失败:"+body.resultMsg, {
								time: 2000
							});
						}
					});
				}
			}
		}
	}
	
</script>